package vg.modules.navigator;

import vg.modules.navigator.components.NavigatorMainComponent;
import vg.services.main_manager.VGMainServiceHelper;
import vg.services.plugin_manager.event_and_request.event.AUIEvent;
import vg.services.plugin_manager.event_and_request.event.UIEventOpenNewGraph;
import vg.services.plugin_manager.interfaces.IPlugin;
import vg.services.user_interface_manager.interfaces.UserInterfaceObserverAdapter;

/**
 * This plugin installs navigator.
 *
 * @author Timur Zolotuhin (e-mail: tzolotuhin@gmail.com)
 */
public class NavigatorPlugin implements IPlugin {
    private NavigatorMainComponent navigatorMainComponent;

	@Override
    public void install() throws Exception {
        navigatorMainComponent = new NavigatorMainComponent();
        VGMainServiceHelper.userInterfaceManager.addElement(navigatorMainComponent, "navigator");

        VGMainServiceHelper.userInterfaceManager.addObserver(new UserInterfaceObserverAdapter() {
            @Override
            public void dispatchEvent(AUIEvent event) {
                switch(event.getType()) {
                    case DEF_OPEN_NEW_GRAPH: {
                        UIEventOpenNewGraph bufEvent = (UIEventOpenNewGraph)event;
                        navigatorMainComponent.addGraphModel(bufEvent.getGraphModelId());
                        break;
                    }

                    case DEF_CHANGE_UI_STYLE: {

                        break;
                    }

                    case DEF_RESET: {

                        break;
                    }

                    case DEF_ADD_VERTEX: {

                        break;
                    }

                    case DEF_ADD_ATTRIBUTE: {

                        break;
                    }

                    default:
                        break;
                }
            }
        });
	}
}
